﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Epsilon.Typing
{
    public class TypeLabel
    {
        public Type Type { get; private set; }
        public PidLabel MaxPidLabel { get; private set; }
        public PidLabel MinPidLabel { get; private set; }
        public SecLabel SecLabel { get; private set; }

        public TypeLabel(Type t, PidLabel pmax, PidLabel pmin, SecLabel s)
        {
            Type = t;
            MaxPidLabel = pmax;
            MinPidLabel = pmin;
            SecLabel = s;
        }

        public static bool operator ==(TypeLabel left, TypeLabel right)
        {
            if (System.Object.ReferenceEquals(left, right))
                return true;

            if ((object)left == null || (object)right == null)
                return false;

            return (left.Type == right.Type) && (left.MaxPidLabel == right.MaxPidLabel) &&
                (left.MinPidLabel == right.MinPidLabel) && (left.SecLabel == right.SecLabel);
        }

        public static bool operator !=(TypeLabel left, TypeLabel right)
        {
            return !(left == right);
        }

        public override string ToString()
        {
            return "{" + Type.ToString() + ", " + MaxPidLabel.ToString() + ", " + MinPidLabel.ToString() + ", " + SecLabel.ToString() + "}";
        }

        public override bool Equals(object obj)
        {
            return (obj is TypeLabel) && this == (TypeLabel)obj;
        }

        public override int GetHashCode()
        {
            return this.ToString().GetHashCode();
        }
    }
}
